<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>

<body>
    账号<input type="text" id="username">
    密码<input type="password" id="password">
    <a href="a">登录</a>
    <button>提交</button>
</body>
<script src="jquery-1.11.0.js"></script>
<script>
    let btn = document.querySelector("button");
    let username = document.querySelector("#username");
    console.log(username);
    let password = document.querySelector("#password");
   
    btn.onclick = () => {
        $.ajax({
            url: "http://jx.xuzhixiang.top/ap/api/login.php",
            type: "get",
            data: {
                username: username.value,
                password: password.value,
            },
            success: function (data) {
                console.log(data);
                 localStorage.setItem("uid", data.data.id)
                 localStorage.setItem("username", data.data.username)
                 localStorage.setItem("token", data.data.token)
                 location.href = "a.html"
            }
        })
       
    }
</script>

</html>